#ifndef __COMPONENT_FLU_H__
#define __COMPONENT_FLU_H__

#include "Component.hpp"
#include "Subsystems/SubsystemTimeOfDay.h"

namespace PocketSurvival
{

    struct ComponentPlayer;

    struct ComponentFlu : public Component
    {
        // 流感爆发
        float fluOnset = 0.0f;
        // 流感持续时间
        float fluDuration = 0.0f;
        // 咳嗽持续时间
        float coughDuration = 0.0f;
        // 打喷嚏持续时间
        float sneezeDuration = 0.0f;
        // 上次生效时间
        double lastEffectTime = 0.0;
        // 上次咳嗽时间
        double lastCoughTime = 0.0;

        ComponentPlayer *componentPlayer;

        inline void startFlu(float fluTime = 900.0f);
        inline void sneeze();
        inline bool hasFlu();
        inline bool isCoughing();

        void cough();
        void fluEffect();

        virtual void update(float dt) override;
        virtual const std::string &getName() const override;
        static const std::string &GetName();
        virtual void load(const nlohmann::json &jsonData) override;
        virtual void save(nlohmann::json &jsonData) override;
        virtual void saveToMsgJson(nlohmann::json &jsonData) override;
    };
    
    inline void ComponentFlu::startFlu(float fluTime)
    {
        fluDuration = fluTime;
    }
    inline void ComponentFlu::sneeze()
    {
        sneezeDuration = 1.0f;
    }
    inline bool ComponentFlu::hasFlu()
    {
        return fluDuration > 0.0f;
    }
    inline bool ComponentFlu::isCoughing()
    {
        return coughDuration > 0.0f;
    }

} // namespace PocketSurvival

#endif
